﻿using System;

namespace Odyssey
{
    public static class SpanConvertExtension
    {
        public static void FromInt32(this Span<byte> spanBuffer, int value)
        {
            spanBuffer[0] = (byte)value;
            spanBuffer[1] = (byte)(value >> 8);
            spanBuffer[2] = (byte)(value >> 16);
            spanBuffer[3] = (byte)(value >> 24);
        }

        public static void FromInt64(this Span<byte> spanBuffer, int value)
        {
            spanBuffer[0] = (byte)value;
            spanBuffer[1] = (byte)(value >> 8);
            spanBuffer[2] = (byte)(value >> 16);
            spanBuffer[3] = (byte)(value >> 24);
            spanBuffer[4] = (byte)(value >> 32);
            spanBuffer[5] = (byte)(value >> 40);
            spanBuffer[6] = (byte)(value >> 48);
            spanBuffer[7] = (byte)(value >> 56);
        }
    }
}
